package com.zbkj.crmeb.enums;

import org.apache.commons.lang3.StringUtils;

/**
 * 功能描述: 日期枚举
 * @Author: wangzh
 * @Date: 2023/3/28 14:00
 */
public enum WeekEnum {
    MONDAY("MONDAY", 1 , "星期一"),
    TUESDAY("TUESDAY", 2, "星期二"),
    WEDNESDAY("WEDNESDAY", 3, "星期三"),
    THURSDAY("THURSDAY", 4, "星期四"),
    FRIDAY("FRIDAY", 5, "星期五"),
    SATURDAY("SATURDAY", 6, "星期六"),
    SUNDAY("SUNDAY", 7, "星期天")
    ;

    private final String code;

    private final Integer weekDay;

    private final String des;

    public String getCode() {
        return code;
    }

    public Integer getWeekDay() {
        return weekDay;
    }

    public String getDes() {
        return des;
    }

    WeekEnum(String code, Integer weekDay, String des) {
        this.code = code;
        this.weekDay = weekDay;
        this.des = des;
    }

    /**
     * 功能描述: 根据code得到对应的周几(数字)
     * @Param: [code]
     * @Return: java.lang.Integer
     * @Author: wangzh
     * @Date: 2023/3/28 14:09
     */
    public static Integer getWeekDayByCode(String code) {
        Integer result = null;
        for (WeekEnum value : WeekEnum.values()) {
            if (StringUtils.equals(code, value.getCode())) {
                result = value.getWeekDay();
                break;
            }
        }
        return result;
    }

    /**
     * 功能描述: 根据code得到枚举
     * @Param: [code]
     * @Return: com.zbkj.crmeb.enums.WeekEnum
     * @Author: wangzh
     * @Date: 2023/3/28 14:10
     */
    public static WeekEnum getEnumByCode(String code) {
        if (StringUtils.isBlank(code)) {
            return null;
        }
        for (WeekEnum trans : values()) {
            if (StringUtils.equals(code,trans.getCode())) {
                return trans;
            }
        }
        return null;
    }
}
